package com.yangrd.airship.upms.domain;

import com.github.wenhao.jpa.Specifications;
import org.apache.logging.log4j.util.Strings;
import org.springframework.data.jpa.domain.Specification;

import java.util.Objects;

/**
 * description: UserSpec
 *
 * @author: yangrd
 * @date: 2021/6/24
 * @version: 1.0
 */
public interface UserSpec {

    /**
     * toSpec
     */
    static Specification<User> toSpec(String username) {
        return Specifications.<User>and().eq(Strings.isNotBlank(username), "username", username).build();
    }

    /**
     * toSpec
     */
    static Specification<User> toSpec(Integer shopId, String username) {
        return Specifications.<User>and().eq(Objects.nonNull(shopId),"shopId", shopId).eq(Strings.isNotBlank(username), "username", username).build();
    }
}
